package com.revenant.driver.utils;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.spec.AlgorithmParameterSpec;
import java.util.Random;

public class AESHelper {
    private static AESHelper instance = null;

    private Cipher cipher;

    SecretKeySpec key = null;

    AlgorithmParameterSpec iv = null;

    public static AESHelper getInstance() {
        String key = "YvllFaIri5Q6dxeG", iv = "sZM5JhqvbkprWA0u";
        return getInstance(key, iv);
    }

    public static AESHelper getInstance(String key, String iv) {
        instance = new AESHelper(key, iv);
        return instance;
    }

    /**
     * 将32bytes的16禁止串压缩成16bytes，充分利用128bits的密钥空间
     *
     * @param hex
     * @return byte[]
     */
    public static byte[] packHex(String hex) {
        int len = hex.length() >> 1;
        byte[] b = new byte[len];
        short k = 0;
        for (int i = 0, j = 0; i < len; i++, j = i << 1) {
            k = Short.parseShort(hex.substring(j, j + 2), 16);
            b[i] = (byte) (k & 0xff);
        }
        return b;
    }

    public static String sha1(String s) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        byte[] b = MessageDigest.getInstance("sha1").digest(s.getBytes("UTF-8"));
        return byte2hex(b);
    }

    public static String byte2hex(byte[] b) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < b.length; i++) {
            if (b[i] >= 0 && b[i] < 16) {
                sb.append('0');
            }
            sb.append(Integer.toHexString(b[i] & 0xff));
        }
        return sb.toString();
    }

    /**
     * 生成可打印的指定长度的随机字符串 asc码范围[32,126]
     *
     * @param length
     * @return
     */
    public static String getRandStr(int length) {
        Random r = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            sb.append((char) (r.nextInt(127 - 32) + 32));
        }
        return sb.toString();
    }

    private AESHelper(String keyStr, String ivStr) {
        try {
            iv = new IvParameterSpec(ivStr.getBytes("utf-8"));
            key = new SecretKeySpec(keyStr.getBytes("utf-8"), "AES");
            cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 加密
     *
     * @return String
     */
    public byte[] encrypt(byte[] txt) {
        try {
            cipher.init(Cipher.ENCRYPT_MODE, key, iv);
            return cipher.doFinal(txt);
        } catch (IllegalBlockSizeException e) {
            e.printStackTrace();
        } catch (BadPaddingException e) {
            e.printStackTrace();
        } catch (InvalidKeyException e) {
            e.printStackTrace();
        } catch (InvalidAlgorithmParameterException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 加密
     *
     * @param txt
     *            txt
     *
     * @return String
     */
/*    public String encrypt(String txt) {
        try {
            byte[] b = this.encrypt(txt.getBytes("utf-8"));
            return Base64.encodeToString(b, 0, b.length, Base64.URL_SAFE);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }*/

    /**
     * 加密
     *
     *            txt
     *
     * @return String
     */
    public String encrypt(String txt) {
        try {
            byte[] b = this.encrypt(txt.getBytes("utf-8"));
            return Base64.encodeToString(b, 0, b.length, Base64.NO_PADDING | Base64.NO_WRAP);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     *
     *
     * @return String
     */
    public byte[] decrypt(byte[] txt) {
        try {
            cipher.init(Cipher.DECRYPT_MODE, key, iv);
            return cipher.doFinal(txt);
        } catch (IllegalBlockSizeException e) {
            e.printStackTrace();
        } catch (BadPaddingException e) {
            e.printStackTrace();
        } catch (InvalidKeyException e) {
            e.printStackTrace();
        } catch (InvalidAlgorithmParameterException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 16 to 2
     * @param hexStr
     * @return
     */
    public static byte[] parseHexStr2Byte(String hexStr){
        if(hexStr.length() < 1)
            return null;
        byte[] result = new byte[hexStr.length()/2];
        for (int i = 0;i< hexStr.length()/2; i++) {
            int high = Integer.parseInt(hexStr.substring(i*2, i*2+1), 16);
            int low = Integer.parseInt(hexStr.substring(i*2+1, i*2+2), 16);
            result[i] = (byte) (high * 16 + low);
        }
        return result;
    }


    /**
     * 2 to 16
     * @param buf
     * @return
     */
    public static String parseByte2HexStr(byte buf[]){
        StringBuffer sb = new StringBuffer();
        for(int i = 0; i < buf.length; i++){
            String hex = Integer.toHexString(buf[i] & 0xFF);
            if (hex.length() == 1) {
                hex = '0' + hex;
            }
            sb.append(hex.toUpperCase());
        }
        return sb.toString();
    }

    public String decrypt(String txt){
        try {
            cipher.init(Cipher.DECRYPT_MODE, key, iv);
            byte[] b = txt.getBytes();
            b = Base64.decode(b, 0, b.length, Base64.NO_PADDING | Base64.NO_WRAP);
            b = cipher.doFinal(b);
            return new String(b, "utf-8");
        } catch (IllegalBlockSizeException e) {
            e.printStackTrace();
        } catch (BadPaddingException e) {
            e.printStackTrace();
        } catch (InvalidKeyException e) {
            e.printStackTrace();
        } catch (InvalidAlgorithmParameterException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     *
     *
     * @return String
     */
    /*public String decrypt(String txt) {

        try {
            cipher.init(Cipher.DECRYPT_MODE, key, iv);
            byte[] b = txt.getBytes();
            b = Base64.decode(b, 0, b.length, Base64.URL_SAFE);
            b = cipher.doFinal(b);
            return new String(b, "utf-8");
        } catch (IllegalBlockSizeException e) {
            e.printStackTrace();
        } catch (BadPaddingException e) {
            e.printStackTrace();
        } catch (InvalidKeyException e) {
            e.printStackTrace();
        } catch (InvalidAlgorithmParameterException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }*/

    public static void test() {
        String txt = "123456";
        AESHelper aes = AESHelper.getInstance("YvllFaIri5Q6dxeG","sZM5JhqvbkprWA0u");
        String x = aes.encrypt(txt);
        System.out.println(x);
    }

    public static void main(String[] args) {
        AESHelper aes = AESHelper.getInstance();
        String txt =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PSjh1SVdBeWUrbVFKYWZjR0VwVnJQcVB3N3ZLd05Jek9QMWhhbm9pUlI5T3RGc2N6aW9uQzNEeHpuWUc1VCtMZGs0am15YlRuK0pXUVJydGV1N2VRbkkyTEhpbkZXWk8veUtKMU9hY1h2bnZjbEYwNzJDeFI0VzhLbWN1eEtqVnhBQ1o5NUZBWE9sUXJaZ29aeWRkM3VibFZTR3VwSUttTmtJMWJKcCtYRGMySWh3ZFQ3R0YvanVtTTNDbEVwNGgyOHY3c0ZHNWdXQUhRVGpsVW9SbGxzdmsvOCs2UmZERUt0VzQ2QzFaK09sTWUzNy9GVUFGQXZ0UmNVWHhHNEFCTy9rYVRhN1pyb29TQlZydmEyWjBPRm1taE1TMThoYi9SSitjRWt6N1pvSjRycEpURUNBeFk";
        String baseDecode = cn.hutool.core.codec.Base64.decodeStr(txt);
        System.out.println(baseDecode);
        System.out.println(aes.decrypt(baseDecode));
    }
}

